package basisRouter

import (
	"github.com/Sir-yuChen/funAnalyse/api"
	"github.com/Sir-yuChen/funAnalyse/global"
	"github.com/Sir-yuChen/funAnalyse/middleware"
	"github.com/gin-gonic/gin"
)

type UserRouter struct{}

func (s *UserRouter) UserInfoRouter(Router *gin.RouterGroup) {
	userRouter := Router.Group(global.ROUTER_GROUP_USER)
	userRouterTokenAndCasbin := Router.Group(global.ROUTER_GROUP_USER).Use(middleware.JWTAuth()).Use(middleware.CasbinMiddleware())
	userRouterToken := Router.Group(global.ROUTER_GROUP_USER).Use(middleware.JWTAuth())
	baseApi := api.ApiGroupApp.BasisApiGroup.UserApi
	{
		userRouter.POST(global.API_USERLOGIN.BasePath, middleware.CheckApiResourcesMiddleware(global.API_USERLOGIN), baseApi.UserLogin)
		userRouter.POST(global.API_USERREGISTER.BasePath, middleware.CheckApiResourcesMiddleware(global.API_USERREGISTER), baseApi.UserRegister)
		//查用户集合 或导出 todo 暂时不添加权限token认证
		userRouter.GET(global.API_USER_LIST.BasePath, middleware.CheckApiResourcesMiddleware(global.API_USER_LIST), baseApi.GetUserList)
	}
	{
		userRouterToken.GET(global.API_USER_LOGIN_OUT.BasePath, middleware.CheckApiResourcesMiddleware(global.API_USER_LOGIN_OUT), baseApi.UserLoginOut)
	}
	{
		userRouterTokenAndCasbin.GET(global.API_USERINFO.BasePath, middleware.CheckApiResourcesMiddleware(global.API_USERINFO), baseApi.GetUserInfo)                  // 获取用户信息
		userRouterTokenAndCasbin.POST(global.API_UPDATE_USERINFO.BasePath, middleware.CheckApiResourcesMiddleware(global.API_UPDATE_USERINFO), baseApi.UpateUserInfo) // 修改手机号或密码
	}
}
